Skip to content

Centred on whole pixels: whole line boxes, even icons, and a renderer check - #192

Merged
agorischek merged 2 commits into
mainfrom
agorischek/whole-pixels
Nov 23, 2026
Merged

agorischek merged 2 commits into
mainfrom
agorischek/whole-pixels

Conversation

@agorischek

@agorischek agorischek commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Polish step (d), stacked on #190 (its base; this retargets to main once #190 merges).

Why

Unitless line heights and 1em icons put bands, pills and centred icons on half pixels. A 13px label in a 1.5 line is 19.5px, and a 13px icon leaves odd room in an even band, so a centred icon sat a half pixel off. The rule: UI spacing never settles on half pixels.

Kit and SDK

  • Whole line boxes: pk-label rounds its line box up to a whole pixel (round(up, 1lh, 1px)), so a band or pill sized by labels is whole (19.5 → 20).
  • Even icons: SDK icons are even squares, round(1em, 2px), so a 13px font's icon is 14px.
  • Group titles: the icon is centred with the label instead of being lowered by baseline arithmetic, so it centres on the capitals and on whole pixels (11px above and below in a 36px band).
  • Whole rather than even: I first rounded line boxes to even pixels, but that grew text-diff's 21px lines to 22px and moved long pages by up to 21px. Whole rounding keeps every centred box on whole pixels too (the check passes), with far smaller moves.

Renderers

  • Database: rows keep their 32px rhythm. Under a row's 1px rule there are 31px of room, which an even icon can't centre in, so the row's status icon is odd and matches the name's size (13px), sitting 9px above and below. Moving to a 33px pitch would change every card's height and the layout's row constants.
  • Agentic workflows: the stale-lock pill holds the lock as its label, with the words as a pk-label and the icon centred beside them.

Check: centred-pixels (probe call pixels)

  • What it holds: a painted box (icon, pill, mark) centred in a bar, chip or button (its nearest painted ancestor, up to 48px across, with gaps up to 16px) must sit at equal, whole-pixel gaps.
  • Collapsed tables: a collapsed table rule counts half to each cell, and the rule below is read from the next row across table sections.
  • Deliberate negative: labels.spec restores 1em icons and unrounded lines; the probe then finds the band icons off by half a pixel.
  • Violations found and fixed:
    • kit band icons and code-statistics pills (at 3.27px either side);
    • status-tab icons;
    • database row icons (9.5/9.5);
    • agentic-workflows matrix and lock-pill icons.
  • Verified:
    • checks.spec and labels.spec on chromium-desktop, webkit-desktop and chromium-mobile;
    • every renderer's Node tests;
    • oxfmt --check;
    • check --fast.

Where text moves more than 1px

I measured every text node in the top 600px of all 77 scenarios against #190. Text within a band, pill or row moves at most about 1px. Larger moves:

  • Cumulative, down long pages: each band or row taller by under a pixel adds up. text-diff captions move 2px and group labels 1.75px; runtime-policy rows move 2 to 2.5px; a runtime-policy chip moves 1.75px.
  • runtime-policy/monitor-mode: one chip's text wraps a word earlier, because the 14px icon is a pixel wider.
  • database/extensions: a tag's status tab re-centres, so its "Added" moves 5px sideways.
  • Group titles: 1px to the right, because the icon is a pixel wider.

Before and after, per renderer (2×: before left, after right; light above, dark below)

agentic-workflows

agentic-workflows before and after

api

api before and after

code-statistics

code-statistics before and after

database

database before and after

dependency-injection

dependency-injection before and after

file-packing

file-packing before and after

gallery

gallery before and after

graph

graph before and after

runtime-policy

runtime-policy before and after

text-diff

text-diff before and after

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The measurement logic still skips inline replaced elements and mishandles ancestor transparency and table borders, causing missed checks and false centring failures.

4 open issues
What changed in this PR

Builds on #190’s capital-centred labels to reduce half-pixel spacing in renderer controls and add a shared check for whole-pixel centring.

Changes:

  • Rounds label line boxes to whole pixels and SDK icons to even sizes.
  • Adjusts group titles, database status icons, and workflow lock pills.
  • Adds the centred-pixels probe, check, regression coverage, and documentation.
File Description
packages/​renderers/​testing/​test/​helpers.test.mjs Tests pixel-check reporting and updates the check count.
packages/​renderers/​testing/​src/​types.ts Defines pixel measurements and check identifiers.
packages/​renderers/​testing/​src/​probe.ts Registers the pixels probe call.
packages/​renderers/​testing/​src/​measure/​pixels.ts Measures centred boxes for unequal or fractional gaps.
packages/​renderers/​testing/​src/​measure/​labels.ts Shares inner-edge measurements and handles next-row rules across table sections.
packages/​renderers/​testing/​src/​measure.ts Exports the pixel measurement function.
packages/​renderers/​testing/​src/​checks/​labels.ts Adds the whole-pixel centring check.
packages/​renderers/​testing/​src/​checks/​catalog.ts Adds the check’s title and description.
packages/​renderers/​testing/​README.md Documents the new check.
packages/​renderers/​sdk/​icons.css Rounds icons to even pixel dimensions.
packages/​renderers/​kit/​styles/​status.css Rounds label line boxes up to whole pixels.
packages/​renderers/​kit/​styles/​layout.css Centres group icons alongside labels.
packages/​renderers/​harness/​browser/​labels.spec.ts Adds a deliberate negative test for fractional gaps.
packages/​renderers/​database/​src/​styles.css Uses odd-sized status icons within the existing row rhythm.
packages/​renderers/​agentic-workflows/​src/​styles.css Centres lock-pill contents without trimming their wrapper.
packages/​renderers/​agentic-workflows/​src/​card.tsx Wraps lock text in pk-label.
docs/​guides/​renderer-kit.md Extends label and icon sizing guidance.
docs/​guides/​develop-a-renderer.md Adds whole-pixel centring guidance for renderer authors.

Review effort: Balanced

@agorischek
agorischek force-pushed the agorischek/cap-labels branch from b3e00b6 to 4da3a73 Compare November 23, 2026 00:07
@agorischek
agorischek force-pushed the agorischek/whole-pixels branch 3 times, most recently from 831feaa to dfd48d9 Compare November 23, 2026 02:21
Base automatically changed from agorischek/cap-labels to main November 23, 2026 02:36
… check

Polish step (d). The user's rule: UI spacing never settles on half pixels (a
28px control in a 32px row, not a 31px one). Unitless line heights (13px x 1.5
= 19.5px) and 1em icons (13px) made bands and pills fractional and left odd
room around centred icons, so they sat a half pixel off.

- Kit `pk-label` rounds its line box up to a whole pixel, so a band or pill
  sized by labels is whole (19.5 -> 20).
- SDK icons are even squares, `round(1em, 2px)`: a 13px font's icon is 14px.
- A group title centres its icon with its label instead of lowering it by
  baseline arithmetic, so the icon centres on the capitals and on whole
  pixels.
- Database rows keep their 32px rhythm. Under a row's 1px rule there is 31px of
  room, so the row's status icon is odd, the name's size (13px), and centres at
  9px either side.
- The agentic-workflows stale-lock pill holds the lock as its label: words as a
  `pk-label`, the icon centred beside them.
- `centred-pixels` (probe call `pixels`): a painted box centred in a bar, chip or
  button (nearest painted ancestor up to 48px across, gaps up to 16px) sits at
  equal, whole-pixel gaps. A collapsed table rule counts half to each cell, and
  the row below's rule is read across table sections.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@agorischek
agorischek force-pushed the agorischek/whole-pixels branch from dfd48d9 to add4edb Compare November 23, 2026 02:42
…ls measured as drawn

- A box inside an opacity: 0 container isn't held (effectiveOpacity); a replaced element (img, canvas, …) is a box though inline.
- A collapsed table cell's room is inside half of each rule it shares beside it (innerSides), and the rule under it is
  the cells' directly below it, not the next row's widest (innerEdges).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@agorischek
agorischek merged commit d6a0c31 into main Nov 23, 2026
51 checks passed
@agorischek
agorischek deleted the agorischek/whole-pixels branch November 23, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants